home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / TCP / TCP2Serial-100 / Documentation next >
Text File  |  1994-08-20  |  4KB  |  96 lines

  1. TCP2Serial v1.0.0 © 1994 Peter N Lewis.
  2. This program is freeware.
  3.  
  4. • Contents
  5.  
  6.       Using TCP2Serial
  7.       Limitations
  8.       Small Print
  9.       Warranty
  10.       Fine Print
  11.       Version History
  12.       Acknowledgements
  13.  
  14. • Using TCP2Serial
  15.  
  16. TCP2Serial sits in the background and waits for a TCP connection on port 1429.  It then feeds any data from that connect to the serial port (well, any CTB tool) and vice versa.  I use this to access a serial printer from a unix machine using a simple perl script.
  17.  
  18. TCP2Serial requires MacTCP and the Communications Toolbox.
  19.  
  20. To use it, simply launch it, and then connect to port 1429 using TCP and send/receive information.
  21.  
  22. You can configure TCP2Serial using ResEdit.  Edit STR# 128, the first string is the name of the tool (defaults to Serial Tool), the second is the configuaration string, and the third is the TCP port to listen on.
  23.  
  24. I use this to talk from a unix machine to a serial printer using this perl script on the unix machine:
  25.  
  26. *****
  27. #!/usr/local/bin/perl
  28.  
  29. $AF_INET = 2;
  30. $PF_INET = 2;
  31. $SOCK_STREAM = 2; # May need to be 1 on non-olaris machines
  32.  
  33. $sockaddr = 'S n a4 x8';
  34.  
  35. &tcpconnect(CONN,"134.7.122.52","1429");
  36.  
  37. while (<>) {
  38.   chop;
  39.   print CONN "$_\r\n";
  40. }
  41. print CONN "\f";
  42. close(CONN);
  43. exit(0);
  44.  
  45. sub tcpconnect {
  46.         local($file,$them,$port,$localport) = @_;
  47.         local($name,$aliases,$proto,$type,$len,$thataddr,$thisaddr,$old,$ret);
  48.         $them = 'localhost' unless $them;
  49.         $port = 79 unless $port;
  50.         $localport=0 unless $localport;
  51.         ($name, $aliases, $proto) = getprotobyname('tcp');
  52.         ($name, $aliases, $port) = getservbyname($port, 'tcp')
  53.                 unless $port =~ /^\d+$/;
  54.         ($name, $aliases, $localport) = getservbyname($localport, 'tcp')
  55.                 unless $localport =~ /^\d+$/;
  56.         ($name, $aliases, $type, $len, $thisaddr) = gethostbyname("localhost");
  57.         ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
  58.         $this = pack($sockaddr, $AF_INET, $localport, $thisaddr);
  59.         $that = pack($sockaddr, $AF_INET, $port, $thataddr);
  60.         socket($file, $PF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
  61.         if ($localport != 0) {
  62.                 bind($file,$this) || die "bind: $!";
  63.         }
  64.         connect($file, $that) || die "connect: $!";
  65.         $old=select($file); $| = 1; select($old);
  66. }
  67. *****
  68.  
  69. • Limitations
  70.  
  71. TCP2Serial requires MacTCP and the Communications Toolbox.
  72.  
  73. • Small Print
  74.  
  75. This program is freeware.  You may use it without charge and it may be distributed on online services.  Commercial distribution of this program is not allowed without my permission.
  76.  
  77. You MAY NOT DISTRIBUTE this program on any disk costing more than $5 without my explicit permission.
  78.  
  79. • Warranty
  80.  
  81. This program should do what I’ve described in this document.  If it doesn’t, you can simply stop using it.
  82.  
  83. • Fine Print
  84.  
  85. Peter Lewis hereby disclaims all warranties relating to this software, whether express or implied, including without limitation any implied warranties of merchantability or fitness for a particular purpose.  Peter Lewis will not be liable for any special, incidental, consequential, indirect or similar damages due to loss of data or any other reason, even if Peter Lewis or an agent of his has been advised of the possibility of such damages.  In no event shall Peter Lewis be liable for any damages, regardless of the form of the claim.  The person using the software bears all risk as to the quality and performance of the software.
  86.  
  87. • Version History
  88.  
  89. 1.0.0
  90.  
  91. • Acknowledgements
  92.  
  93. Hmmm.
  94.  
  95.  
  96.